<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

function smarty_block_news_category($params, $tagdata, $smarty, $repeat){
	if (!isset($params['parent_id'])){
		exit();
	}else{
		$smarty->CI->load->model('news/news_model');
		$result = $smarty->CI->news_model->get_categories(array('parent_id'=>$params['parent_id']),false,false);
		if ($result){
			$new_category = array();
			foreach ($result as $r){
				$r['link'] = create_url('tin-tuc/'.$r['alias'],array('rewrite'=>true));
				$new_category[] = $r;
			}
			$smarty->assign('new_category',$new_category);
		}
	}
	echo $tagdata;
}
